module.exports = ({white})=>{
    return async (ctx,next)=>{
        if(white.includes(ctx.url.split('?')[0]==="/three"?ctx.url.split('?')[0]:ctx.url)){
            await next();
        }else{
            try { 
                // const token = ctx.cookies.get("token");
                const token = ctx.headers.token;
                // console.log(token);
                const data = await ctx.helper.token.verify(token);
                ctx.userInfo = data;
                await next()
            } catch (err){
                ctx.body = {
                    code:401,
                    msg:"token效验失败"
                }
            }
        }
    }
}